<template>
  <div class="login">
    <div>
      <div class="top">
        <img src="../assets/logo.png" alt="">
      </div>
      <div style="height: 10px;">

      </div>
      <div class="main">
        <el-form :model="from" :rules="rules" style="margin-top: 100px;">
          <el-form-item label="用户名称" prop="username">
            <el-input v-model="from.username" style="width: 70%;"></el-input>
          </el-form-item>
          <el-form-item label="用户密码" prop="password" show-password>
            <el-input v-model="from.password" style="width: 70%;"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" style="width: 90%;" @click="logins">立即登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import { login } from '@/http/user'
export default {
  data() {
    return {
      from: {
        username: "",
        password: ""
      },
      rules: {
        username: [
          { required: true, message: '请输入用户名称', trigger: 'blur' },
        ],
        password: [
          { required: true, message: '请输入用户密码', trigger: 'blur' },
        ],
      }
    }
  },
  created() {

  },
  methods: {
    logins() {
      this.$store.dispatch('user/logins', this.from).then((res) => {
        this.$message({
          message: '登陆成功',
          type: 'success'
        });
        this.$router.push('/')
      }, (error) => {
        this.$message.error(error.meta.msg)
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.login {
  width: 100%;
  height: 100vh;
  background-color: #2b4b6b;
  overflow: hidden;

  >div {

    width: 550px;
    height: 300px;
    background-color: #fff;
    margin: 400px auto;
    box-sizing: border-box;
    position: relative;
    box-shadow: 0px 0px 5px #fff;
    border-radius: 4px;

    .top {
      position: absolute;
      left: 175px;
      top: -100px;
      width: 200px;
      height: 200px;
      box-shadow: 0px 0px 8px #ccc;
      border-radius: 50%;
      background-color: #fff;
      box-shadow: 0px 0px 8px #fff;

      >img {
        width: 80%;
        height: 80%;
        border-radius: 50%;
        display: block;
        margin: 10% auto;
        background-color: rgba(204, 204, 204, 0.227);
      }
    }

    .main {
      display: block;
      margin: 80px 80px;



    }

  }
}
</style>